package com.example.designmode.flyweight

import org.junit.Test


/**
 * 用户角色
 *
 * @author zhouronghua
 * @time 2022/3/9 9:28 下午
 */
class Client {

    /**
     * 测试享元模式
     *
     * @author zhouronghua
     * @time 2022/3/9 9:29 下午
     */
    @Test
    fun testFlyWeightMode() {
        val colorArray = arrayOf("蓝色", "黄色", "绿色", "白色")
        val nameArray = arrayOf("LBox", "IBox", "OBox")
        for (i in 0 until 100) run {
            var box: AbstractBox = BoxFactory.getBox(nameArray.get(i % nameArray.size))
            box.display(colorArray.get(i % colorArray.size))
        }
    }
}